package com.opencore.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.opencore.bean.ProcesarDTEBean;

/**
 * Servlet implementation class EjecutaServlert
 */
@WebServlet("/EjecutaServlert")
public class EjecutaServlert extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * Default constructor. 
	 */
	public EjecutaServlert() {
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String factura = request.getParameter("factura");
		PrintWriter out = response.getWriter();
		out.println("Se ejecuta proceso de recargar de datos en servlet:"+factura);
		long start = System.currentTimeMillis();
		ProcesarDTEBean.procesa();
		long end = System.currentTimeMillis();
		long res = end - start;
		out.println("Tiempo de proceso en segundos: "+res/1000);
		request.getRequestDispatcher
		("/visualizarDTE.jsp").forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	}

}
